<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="pits.dto.EmployeeDTO"%>
<%@ page import="pits.dao.EmployeeDAO"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

<portlet:defineObjects />

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">
	function getForm(namespace, name) {
		return document.forms[namespace + name];
	}
 
	function submitForm(namespace, name, action, selectedEmpID) {
		var frm = getForm(namespace, name);
		frm.txtAction.value = action;
		frm.submitLink.value = "Menu.jsp";
		frm.submit();
	}
</script>

</head>
<body>
<form name="<portlet:namespace/>myForm" action="<portlet:actionURL/>"
	method="POST"><input type="hidden" name="txtAction" /> <input
	type="hidden" name="submitLink" />
<p align="right">You are logging in as <a href="#"
	onclick="submitForm('<portlet:namespace/>', 'myForm','home')"><b>${sessionScope.userName}</b></a>
! &nbsp; <a href="#"
	onclick="submitForm('<portlet:namespace/>', 'myForm','logout')">Logout</a>
</p>
</form>

<form name="<portlet:namespace/>editEmployeeInfoForm"
	action="<portlet:actionURL/>" method="post"><input type="hidden"
	name="txtAction" /> <input type="hidden" name="submitLink" /> <br>
<table align="center">
	<tr class="title">
		<td>
		<h1><a href="#">Personal Information</a></h1>
		<hr>
		</td>
	</tr>
	<%
	EmployeeDTO emp = EmployeeDAO.getEmployeeInfo(Integer.parseInt(session.getAttribute("selectedEmpID"))).get(0);
	%>
	<tr>
		<td>
		<table border="1" width="100%">
			<tr>
				<td align="left" valign="middle">Name</td>
				<td align="left" valign="middle"><input width="100%"
					type="text" name="txtName" value=<%=emp.getName() %> /></td>
			</tr>
			<tr>
				<td align="left" valign="middle">Birthdate&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td align="left" valign="middle"><script>
					DateInput('txtBirthday', true, 'DD-MM-YYYY', '<%=emp.getBirthday() %>');
				</script> <%--input width="100%" type="text" name="txtBirthday" value="${sessionScope.employee.birthday}"/--%>
				</td>
			</tr>
			<tr>
				<td align="left" valign="middle">Address</td>
				<td align="left" valign="middle"><input width="100%"
					type="text" name="txtAddress" value='<%=emp.getAddress() %>' /></td>
			</tr>
			<tr>
				<td align="left" valign="middle">Phone</td>
				<td align="left" valign="middle"><input width="100%"
					type="text" name="txtPhone" value='<%=emp.getPhone() %>' /></td>
			</tr>
			<tr>
				<td align="left" valign="middle">Email</td>
				<td align="left" valign="middle"><input width="100%"
					type="text" name="txtEmail" value='<%=emp.getEmail() %>' /></td>
			</tr>
			<tr>
				<td align="left" valign="middle">Gender</td>
				<td align="left" valign="middle"><select name="txtGender">
					<option id="o1" value="0">Male</option>
					<option id="o2" value="1">Female &nbsp;&nbsp;</option>
				</select> <script type="text/javascript">
					var gd = <%=emp.getGender() %>;
					if (gd == "0") {
						document.getElementById("o1").setAttribute("selected", "true");
					} else {
						document.getElementById("o2").setAttribute("selected", "true");
					}
				</script></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td><input type="button" value="Update"
			onclick="submitForm('<portlet:namespace/>', 'editEmployeeInfoForm','confirm')" />
		&nbsp;&nbsp;&nbsp; <input type="button" value="Cancel"
			onclick="submitForm('<portlet:namespace/>', 'editEmployeeInfoForm','cancel')" />
		</td>
	</tr>
</table>
</form>

</body>
</html>